﻿using System;

namespace Equation.Enterprise.Utilities.Log
{
    public class Logger
    {
        public static void LogError(string error)
        {
            LogError(error, string.Empty);
        }

        public static void LogError(string error, string logKey)
        {
            var logger = LoggerFactory.FirstOrDefault(logKey, LogLevel.Error);
            if (logger != null)
                logger.Error(error);
        }

        public static void LogError(Exception exception)
        {
            LogError(exception, string.Empty);
        }

        public static void LogError(Exception exception, string logKey)
        {
            var logger = LoggerFactory.FirstOrDefault(logKey, LogLevel.Error);
            if (logger != null)
                logger.Error(exception);
        }

        public static void LogInfo(string info)
        {
            LogInfo(info, string.Empty);
        }

        public static void LogInfo(string info, string loggerKey)
        {
            var logger = LoggerFactory.FirstOrDefault(loggerKey, LogLevel.Info);
            if (logger != null)
                logger.Info(info);
        }

        public static void LogDebug(string debug)
        {
            LogDebug(debug, string.Empty);
        }

        public static void LogDebug(string debug, string loggerKey)
        {
            var logger = LoggerFactory.FirstOrDefault(loggerKey, LogLevel.Debug);
            if (logger != null)
                logger.Debug(debug);
        }

        public static void LogWarning(string warning)
        {
            LogWarning(warning, string.Empty);
        }

        public static void LogWarning(string warning, string loggerKey)
        {
            var logger = LoggerFactory.FirstOrDefault(loggerKey, LogLevel.Warning);
            if (logger != null)
                logger.Warn(warning);
        }
    }
}
